Fixed shaping and some bugs