improve stability, logging and testing