Add better comments and clean up