Initial import of package and some minor fixes