bug fixes, tested and running on sbc