Restructure

Restructured code to separate independent components.