Minor refactoring for better readability, smaller binary.
Fixed display clearing on error.