small bug fixes, exception handling added