Updated source code and cleaned it up for the last submit