Added layer management. Fixes #7