Some runtime errors fixed