Cleaned up code, added KSS comments