fixed bugs, some improvemnts