Fixed some bugs
Fixed some warnings.