moved helper definitions to a unified header and made error code macro names more understandable