added singleton and statics support
moved code around