Refactor. Apply const to every declaration possible. Use scoping where appropriate.