Using new features from fog-core to fix build on 1.8.7 and improve code