Reworked query and createtable functions for 2x speedup and cleaner code. Also reworked API to prepare for readdlmsql function