Sql

Here are a few fixes and improvements I`ve been doing in the last days to be able to use it in our production app. I will probably keep improving this fork.

MotionModel has been a great friend. Thanks!