Fixed circular dependencies

Changed the way the models are set up so that circular dependencies are
no longer a problem. This allows us include posts in threads and threads
into posts.

This was acheived by always declaring the object to return first then
exporting it right away. Then requiring all other dependencies. Then any
functions that needs to be added to the object is added last.