Cleaned up q-learning code a bit.