fix some compile and style problems
switch to probabilistic pushing of keys