Fixed some bugs...
Merging local modifications.