some bug fixes (++ optimized out)