Almost working compact implementation (bias needs work)