Updated code, and cleanup