move core code to top
more consistency: n -> bn, p -> point