Massive code clean up