Flash routines have been moved into separate file in order to improve code cleanliness

The flash routines make use of friend classes which is a bit complicated but computationally efficient and helps to keep the interface cleaner

Signed-off-by: Ian bell <ian.h.bell@gmail.com>