Code cleanup and commenting

Comments added and layout cleaned up.