Changes for MATlab compatibility