Refactoring of error output, added error code system