make some classes and objects package private
simplify function
added access modifiers and moved classes to other packages