fixed #39 and solved #52 (hopefully)