Removed wild imports and corrected all the warnings
Changed models according to the latest design, to support synonyms easily. Changed all the necessary logic also to support the new database schema