Restructure.
Fixed some warnings