Massive code optimisation.

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