Update from 0.37->0.4

Very hasty changes made, but I see no apparent bugs