remove unused gems and refactor code