Updated code structure.

This closes #4