Refactor magic methods.

Signed-off-by: crynobone <crynobone@gmail.com>