Integration complete, might need testing, fixes #4