Modified to correct errors in the inheretance (amongst other things)