Rebase and proper compilation

bring the code up wot date with base code and fixing it so that it compiles properly,