Complete refactor of pivotal gem