address review comments on osrandom engine, reorganize some code