Fix cfg create and error handling