Fix some syntax or runtime errors