Fixed some bugs and got first segment basically working.