Fixed bugs for custom spritesheet

Still not tested with custom spritesheet but should work now #91