Added some error handling in Kernels.
errors handled better
update q now uses discrete random function
added some forgotten files. Upadte z is now very slow (non-kernel), due to array copying.