Replaced some usages of Error with Exceptions