WIP Montecarlo C Rewrite

Full rewrite of montecarlo routines in C.

Work in progress