Fix error handling
Style tweaks