Address comments and clean up code