Cleaned up code and added some ANSI fixes