PEP8 Compliance.
	modified:   core/models/application.py
Use django transactions and select_for_update to prevent race condition in instance_status_history.
	modified:   core/models/instance.py