Mostly, some refactoring

Signed-off-by: shockley_lab <shockleylee@gmail.com>