Added callbacks to endpoints. Refactoring

Signed-off-by: Robert Wettstädt <robert.wett@gmail.com>