Refactors whole gem to a proper rails gem