Fixing style and runtime errors