Use singleton and simplify some stuff.

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