Made 3.0 branch from timsnadden's 3.1