Merge if statements
Print errors on stderr
Write function that properly releases board memory