remove some unused code
merge working in magic mode
simplified set() function, fixed some magic mode bugs
fix magic mode bug