Better exception handling. Has to be improved still, though.