total rewrite in C

New options and more in depth