Fixed several bugs (i.e. inconstent break behavior from Matlab).