Added errorcodes and intent handling