Cleaned up the code and added support for handling the 49 test queries.