Code clean up and removal of external dependencys