improved rotating sqlite file; improved few syntax