Added changes made by @heldplayer