First draft of refactoring complete
Cleaned up A_problem, Q_problem. Tests now passing