Made some bug fixes and minimized storage() usage.