Added Logger
Fixed some bugs.