It seams to me that you have the derivatives backward. The previous definitions look correct.