minor syntax fixes and rails 4 refactoring