Major rewrite to make more functional