Refactored quite a bit. Started refining the APIs