Clean up and comments. Refactored database variables for easier understanding.