Bug fixes + exception catching