Add update_gems script & refactor gem handling lib