added get_command() and process_command() functions. misc refactoring.