added struct headers to have more flexible implementation; comments refactored