Changed references to pointers, removed temporary reference returns. General improvements.
Accidentally had 'using namespace std;' which I removed.