Moved old code to separate file before code rewrite