Further refactoring. Handling Caps. Bug Fixes.