Wrap application in class and improve exit codes.