Updated. Fixed few small logical bugs.