fixed many level-related bugs and added save function to level editor