Fixed saving and some error handling