Eliminated some unnecessary exceptions and simplied code, added comment