Performance tuning and some enhancements