Cleanup: Add appropriate scope keywords, re-order functions based on call order