Added the autoResize option and some minor code fixes