Added some new features. Things are lining up with binbin's code