improved cmake configuration, refactored style for all the files, added license, fixed some bugs, replaced option -R for twistandturn