Few speed improvments and couple of bug fixed