Refactored the lib. Changed demo a bit.