Some files reorganized. Fixed some little bugs.

Some files reorganized. Fixed some little bugs.