Share database session between threads when inserting lrm positions and fix package structure