correcting MSP implementation, optimizations