Clean implementations of Value at Risk optimization