Fixes.
fix for mysql console
bugfix and slight optimization