Added prorotypes and as always many fixes