Fixed some minor issues and added exception