Fixed some TODOs, thread-safety, documentation