More detailed error handling for global functions
Fix constant value check