new magic, fix many bugs