general bug fixes + copyright header inserted