Fixed serveral bugs, need fixed more bugs yet.