Trying to simplify stuf 1 of N
Moved static functions into separate class
Minor improvements