optimzied threading and serialization, source code clean up