Clean up program logic
More logic cleanup.