solved null pointer, added close function, updated package structure