Major changes to code. -asherlaw

This is the most up-to-date version