Clean up code, fix save stats bug, reduce file size, fix other minor bugs