fixed some bugs, moved functional code to feature class, some bugs remaining