Updated libs and rewrote in oo style.