Patched some bugs with automatic resizing