Add blocking and cleanup

Add gcc optimisation flag.