backend stuff and small code cleanup