Full HF-code finished, but seems  a bit buggy