Fixed lotsa stuff. Added sampling class