Catch errors

@Cokenias I think this is now in a pretty good state.