Added additional functionality and cleaned up a lot of extra stuff.