New constructor, minor code fixes