Working out some tedious bugs