modularized the code for easy import, separated and commented demo, updated readme