Removed external imports and added compatibility with virtualenv