First working version. Needs a lot of cleaning.
Code cleaning
Support multiple foreingKeys