Cleaned up code, fix comments