Various updated

 - Remove debug code
 - Improve formatting
 - Remove write() function