smallfix and code design improvements