Added support for table prefixes

And few other minor fixes