docblocks and logic fixes