Closes #7 #8 and fixes other minor issues