Minor efficiency changes. Completed till p7