simplify, clean up and make more efficient

Signed-off-by: Joshua Rubin <jrubin@zvelo.com>