Added more comments and cleaned up code

Added more comments and cleaned up the code for better and easier
reading