This is definitely a step in the right direction.  I'd like to modularize this even more, so you can access portions of this without needing to do the queries for the rest (which can be expensive).