Better design. Closes #400.