Clean up Code and add comments