Minor changes. Added exceptions.