some fixes and speed-upes