Fixed memset and malloc bugs. Dimming getting closer