Refactor.

Basically not a single line is left untouched.
It uses properties instead of functions.
It uses __slots__ to save memory.
It implements __bool__ for easy use in if statements.