We study plurisubharmonic functions and their applications to K\"ahler geometry. We begin by studying regularity of envelopes of plurisubharmonic functions, particularly when the reference form is degenerate. This is then applied to show regularity of geodesic of K\"ahler metrics on singular varieties, as well as regularity of certain geodesic rays....