Serveral bugs fixed.