Some rework on internal API to make it more flexible

Signed-off-by: crynobone <crynobone@gmail.com>