Updated comments, cleaned up code