added plenty of ifdef guards to account for TR1 / C++11 and libc++ issues -- this is becoming increasingly nasty and will be hard to maintain -- got some better ideas on how to solve the issue?