Three-level implementation
Many bugs corrected
Version 0.4.0