Fixed variable names, added keyboard interrupt protection.