Fixes errors and refactors code. Proof of concept for loc based tracking.