Small bug fixes - error handling