Fixing runtime errors