Fixed most of the coding issues reported by Krazy