Fixed bugs.
Added a function of z.