framework: Added more error checking