Complete, maybe with 1 or 2 minor bugs