many tweaks, still unstable in release mode