Better error handling
Fix return value on empty graphs